//路由文件
import { createRouter, createWebHashHistory, createWebHistory } from "vue-router";
import Home from '@/views/Home.vue'
import About from '@/views/About.vue'
import Detial from '@/views/detial.vue'
import News from '@/views/News.vue'

const router = createRouter({
    // history: createWebHashHistory(),   //Hash模式
    history: createWebHistory(), //History模式
    routes: [
        { name: 'shouYe', path: '/home', component: Home },
        {
            name: 'xinWen', path: '/news', component: News
            , children: [
                {
                    name: 'xiangXi', path: 'detail', component: Detial
                    , props(route) { return route.query } // query模式下，将参转成props方式
                } //注意在Children中的path下不需要使用/， Questry模式

                // {
                //     name: 'xiangXi', path: 'detail/:id/:name/:content?', component: Detial,
                //     props: true  // params模式下， 将参数转成props方式
                // }  //？表示content可以不传，Paramter模式
            ]
        },
        { name: 'guanYu', path: '/about', component: About },
        { path: '/', redirect: '/home' } //重定向
    ]
})
export default router